// Copyright (C) 2005 Taylor L. Riché <riche@cs.utexas.edu>
//  
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software 
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// 	$Id: CppData.java 216 2005-08-25 20:13:42Z richetl $	
//


import java.io.*;
import java.util.*;

class CppData
{

    public class DataItem {
	private String name;
	private String type;
	private String value = null;

	public void setName(String n) {
	    name = n ;
	}
	public String getName() {
	    return name;
	}
	public void setType(String t) {
	    type = t;
	}
	public String getType() {
	    return type;
	}
	public String getValue() {
	    return value;
	}
	public void setValue(String s) {
	    value = s;
	}
    }

    private LinkedList dataList;

    public CppData() {
	dataList = new LinkedList();
    }

    public void print(PrintStream file) {
	Iterator data = dataList.iterator();
	int listSize = dataList.size();
	for(int i = 0; i < listSize; i++) {
	    DataItem item = (DataItem)data.next();
	    file.println("\t" + item.getType() + " " + item.getName() + ";");
	}
    }

    public void print_init(PrintStream file) {
	Iterator data = dataList.iterator();
	int listSize = dataList.size();
	for(int i = 0; i < listSize; i++) {
	    DataItem item = (DataItem)data.next();
	    if(item.getValue() != null) {
		file.print(", " + item.getName() + "(" + item.getValue() + ")");
	    }
	}
    }

    public void addData(DataItem i) {
	dataList.addLast(i);
    }

}
